<template>
  <div class="item" @click="linkDetail">
    <img v-if="content.avater" class="user" :src="content.avater" />
    <div class="user" v-else>
      {{ nameLastTwoWord }}
    </div>
    <div class="content">
      <div class="name">{{ content.userName }}</div>
      <div class="copy">隶属单位：{{content.orgName}}</div>
      <div class="title">{{ content.taskName }}</div>
      <div class="time">{{ content.startTime | timeFormatWithYear }} - {{ content.endTime | timeFormat }}</div>
    </div>
    <img class="btn" src="@/assets/index/arrow-right.png" />
  </div>
</template>

<script>
import { formatTime } from "@/utils";
export default {
  props: {
    content: {
      type: Object,
      default: () => {}
    }
  },
  computed: {
    nameLastTwoWord() {
      return this.content.userName.slice(-2);
    }
  },
  filters: {
    timeFormat(time) {
      return formatTime(time, "MM月dd日");
    },
    timeFormatWithYear(time) {
      return formatTime(time, "yyyy年MM月dd日");
    }
  },
  methods: {
    linkDetail() {
      this.$router.push({
        path: "/normal/achievement-detail",
        query: {
          id:this.content.dataId,
          type:this.content.taskType
        }
      });
    }
  }
};
</script>

<style scoped lang="scss">
.item {
  display: flex;
  background: #fff;
  border-radius: 8px;
  margin-bottom: 16px;
  padding: 16px;
  &:active {
    background: #f9f9f9;
  }
  .content {
    flex: 1;
    color: #333;
    font-size: 13px;
    line-height: 18px;
    .name {
      line-height: 20px;
      font-size: 14px;
    }
    .copy {
      color: #a3a7ad;
      font-size: 12px;
      margin-top: 3px;
      margin-bottom: 12px;
    }
    .time {
      color: #a3a7ad;
      margin-top: 6px;
    }
  }
  .user {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    margin-right: 12px;
    background: #2492ff;
    color: #fff;
    text-align: center;
    line-height: 40px;
    font-size: 14px;
  }
  .btn {
    width: 32px;
    height: 32px;
  }
}
</style>
